package cn.zjutleo.village_server.controller;

import cn.zjutleo.village_server.entity.EchartsRepairApplyData;
import cn.zjutleo.village_server.entity.ViewDispatchRepairInfo;
import cn.zjutleo.village_server.service.EchartsDataService;
import cn.zjutleo.village_server.service.ViewDispatchRepairInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: 张坤
 * @DateTime: 2021/9/1 13:58
 * @Description: 该类用于 TODO
 */
@Api(tags="大数据数据查询/显示")
@RestController()
public class EchartsRepairApplyDataController {
    @Autowired
    ViewDispatchRepairInfoService viewDispatchRepairInfoService;

    @Autowired
    EchartsDataService echartsDataService;

    @ApiOperation("查询报修数据")
    @PostMapping("/api/getEchartsRepairApplyData")
    String getEchartsRepairApplyData(){
        List<ViewDispatchRepairInfo> viewDispatchRepairInfoList= viewDispatchRepairInfoService.selectAll();
        return viewDispatchRepairInfoList.toString();
    }

    @ApiOperation("查询省市区名称")
    @PostMapping("/api/selectAddress")
    List<String> selectAddress(@RequestParam(value = "fuzzySearch") String fuzzySearch){
        return viewDispatchRepairInfoService.selectAddress(fuzzySearch);
    }

    @ApiOperation("按照地址查询对应数据")
    @PostMapping("/api/selectRepairApplyDataByAddress")
    List<EchartsRepairApplyData> selectRepairApplyDataByAddress(String address){
        System.out.println(address);
        return viewDispatchRepairInfoService.selectRepairApplyDataByAddress(address);
    }

    @ApiOperation("查询报修和派单数据")
    @PostMapping(value="/api/selectOrderData",produces="application/json;charset=UTF-8")
    List<String[]> selectOrderData(String addressName){
        if("china".equals(addressName)){
            return echartsDataService.selectOrderData("");
        }
        return echartsDataService.selectOrderData(addressName);
    }
}
